/*
 * meituan.com Inc.
 * Copyright (c) 2010-2018 All Rights Reserved.
 */
package java.zk.example;

import java.util.List;

/**
 * <p>
 * 本地缓存从节点列表
 * </p>
 * @author LvJing
 * @version $Id:WorkersCache.java v1.0 2018/9/4 上午10:49 LvJing Exp $
 */
public class WorkersCache {

    public List<String> workers;

    public WorkersCache(List<String> workers) {
        this.workers = workers;
    }

    /**
     * 对比workers和传入的newWorkers，取出存在于workers中但是不存在于newWorkers中的，这些即被删除的节点
     */
    public List<String> removeAndSet(List<String> newWorkers) {
        workers.removeAll(newWorkers);
        workers = newWorkers;
        return workers;
    }
}
